package com.example.academicsystem.server.controller.teacher;

import com.example.academicsystem.pojo.dto.CourseDto;
import com.example.academicsystem.pojo.dto.TeacherCourseDto;
import com.example.academicsystem.result.PageResult;
import com.example.academicsystem.result.Result;
import com.example.academicsystem.server.service.TeacherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/teacher/course")
@Slf4j
public class TeacherCourseController {
    @Autowired
    private TeacherService teacherService;


    /**
     * 分页查询课程(所有或者根据课程名称模糊查询)
     * */
    @PostMapping("/page")
    public Result<PageResult> teacherCoursePageQuery(@RequestBody CourseDto courseDto){
        log.info("teacherCoursePageQuery");
        PageResult pageResult = teacherService.studentCoursePageQuery(courseDto);
        return Result.success(pageResult);
    }

    /**
     * 删除选课
     * */
    @DeleteMapping("/delete")
    public Result teacherCourseDelete(@RequestBody TeacherCourseDto teacherCourseDto){
        log.info("teacherCourseDelete");
        teacherService.teacherCourseDelete(teacherCourseDto);
        return Result.success();
    }

    /**
     * 新增选课
     * */
    @PostMapping("/insert")
    public Result teacherCourseInsert(@RequestBody TeacherCourseDto teacherCourseDto){
        log.info("teacherCourseInsert");
        teacherService.teacherCourseInsert(teacherCourseDto);
        return Result.success();
    }
}
